const xmlReorder = require('./xmlReorder');
const mwsOrder = require('./mwsOrder');

let m = function(xmlContent, compressed=true) {
    let result = xmlContent;
    Object.keys(mwsOrder).forEach(function(key){
        // let xmlKey = "Message" + key;
        // if (key === '.') { xmlKey = '.'; }
      let xmlKey = key;
      if (key.length > 1 && key[0] === '.') {
        xmlKey = key.substring(1);
      }
        result = xmlReorder(result, xmlKey, mwsOrder[key], compressed);
    });

    // result = xmlReorder(xmlContent, ".", mwsOrder["."]);
    // result = xmlReorder(result, "Message.Product", mwsOrder[".Product"]);
    // result = xmlReorder(result, "Message.Product.StandardProductID", mwsOrder[".Product.StandardProductID"]);
    // result = xmlReorder(result, "Message.Product.RelatedProductID", mwsOrder[".Product.RelatedProductID"]);
    // result = xmlReorder(result, "Message.Product.DescriptionData", mwsOrder[".Product.DescriptionData"]);
    return result;
};

module.exports = m;